from sqlalchemy import Column, Integer, Date, DateTime, Float
from sqlalchemy.sql import func
from backend.config.database import Base


class LoadData(Base):
    """负荷数据表 - 规范化设计"""
    __tablename__ = "load_data"
    
    id = Column(Integer, primary_key=True, autoincrement=True, comment='主键')
    dt = Column(Date, nullable=False, comment='日期')
    t_idx = Column(Integer, nullable=False, comment='时间点(1~96)')
    dtm = Column(DateTime, nullable=False, comment='精确到15分钟的时间戳')
    load_val = Column(Float, nullable=False, comment='实际负荷(MW)')
    created_at = Column(DateTime, default=func.now(), comment='入库时间')
    
    class Config:
        from_attributes = True